using System.Text.Json.Serialization;

namespace Crux.Core.Payloads;
/// <summary>
/// PayloadOfT
/// </summary>
public record Payload<T> : Payload
{
    /// <summary>
    ///
    /// </summary>
    public Payload()
    {
    }
    /// <summary>
    ///
    /// </summary>
    protected Payload(Result result = Result.Error, string? message = null) : base(result, message)
    {
    }
    /// <summary>
    ///
    /// </summary>
    [JsonPropertyName("transports")]
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public T? Transports { get; set; }
    /// <summary>
    ///
    /// </summary>
    /// <param name="transports"></param>
    /// <returns></returns>
    public static Payload<T> Success(T transports) => new Payload<T>(Result.Success)
    {
        Transports = transports
    };

}